<?php
/**
 *
 *
 */
class Yz_Model_Field_Number
    extends Yz_Model_Field_Abstract
{



    /** Initialization value
     *  @return
     */
    public function assignValue($value)
    {
        if (null === $value)
            return $this->getDefaultValue();
        return (int)$value;
    }

    /** Test if a value is a valid number
     *  @param mixed value
     *  @return number
     *  @throw TypeError
     *  @throw NullValueError
     */
    protected function _testValue($value)
    {
        if (! is_int($value)) {
            if (! is_numeric($value))
                throw TypeError::_new_();
            $value = (int)$value;
        }

        return $value;
    }
}
